Option Strict Off
Option Explicit On
Friend Class settings
	Inherits System.Windows.Forms.Form
	
	
	Private Sub cmdAchievements_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdAchievements.Click
		achievements.Show()
	End Sub
	
	Private Sub cmdCampaign_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdCampaign.Click
		Me.Hide()
		Campaign.Show()
	End Sub
	
	Private Sub cmdRestoreDefaults_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdRestoreDefaults.Click
		Dim i As Short
		comboNumPlayers.Text = CStr(4)
		comboNumActions.Text = CStr(10)
		comboExhaust.Text = CStr(3)
		comboNumEachAction.Text = CStr(10)
		comboNumVictory.Text = CStr(12)
		For i = 4 To 5
			lblName(i).Visible = False
			txtName(i).Visible = False
		Next i
	End Sub
	
	Private Sub cmdStart_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdStart.Click
		' write settings to disk
		FileOpen(1, My.Application.Info.DirectoryPath & "/settings.txt", OpenMode.Output)
		Dim i As Short
		For i = 0 To 5
			PrintLine(1, txtName(i).Text)
		Next i
		PrintLine(1, comboNumPlayers.Text)
		PrintLine(1, comboNumActions.Text)
		PrintLine(1, comboExhaust.Text)
		PrintLine(1, comboNumVictory.Text)
		PrintLine(1, comboNumEachAction.Text)
		PrintLine(1, chkAutoEnd.CheckState)
		PrintLine(1, chkSound.CheckState)
		PrintLine(1, chkInterface.CheckState)
		FileClose(1)
		
		Me.Hide()
		game.Show()
		Call game.start_game()
	End Sub
	
	Private Sub cmdStats_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdStats.Click
		'UPGRADE_WARNING: Dir has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
		If Dir(My.Application.Info.DirectoryPath & "/stats_date.txt") = "" Then
			MsgBox("You must compelte at least 1 more game before stats will be available")
		Else
			Stats.Show()
		End If
	End Sub
	
	'UPGRADE_WARNING: Event comboNumPlayers.SelectedIndexChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	Private Sub comboNumPlayers_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles comboNumPlayers.SelectedIndexChanged
		Dim i As Object
		Dim value As Short
		value = CShort(VB6.GetItemString(comboNumPlayers, comboNumPlayers.SelectedIndex))
		
		' mess with the name boxes
		For i = 0 To value - 1
			lblName(i).Visible = True
			txtName(i).Visible = True
		Next i
		For i = value To 5
			lblName(i).Visible = False
			txtName(i).Visible = False
		Next i
		
		comboNumActions.Text = CStr(10)
		If value = 2 Or value = 3 Then
			comboNumVictory.Text = CStr(8)
		ElseIf value > 4 Then 
			comboNumActions.Text = CStr(12)
			comboNumVictory.Text = CStr(18)
			If value = 5 Then comboNumVictory.Text = CStr(15)
			comboExhaust.Text = CStr(4)
		End If
		
	End Sub
	
	
	Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click
		PickActions.Show()
	End Sub
	
	Private Sub settings_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
		
		' do non-file-based settings
		Dim i As Short
		'UPGRADE_NOTE: str was upgraded to str_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
		Dim str_Renamed As String
		For i = 0 To 5
			If i > 0 Then
				lblName(i).Text = "Opponent " & i & ":"
			End If
		Next i
		
		comboNumPlayers.Items.Add(CStr(2))
		comboNumPlayers.Items.Add(CStr(3))
		comboNumPlayers.Items.Add(CStr(4))
		comboNumPlayers.Items.Add(CStr(5))
		comboNumPlayers.Items.Add(CStr(6))
		
		comboNumActions.Items.Add(CStr(10))
		comboNumActions.Items.Add(CStr(11))
		comboNumActions.Items.Add(CStr(12))
		
		comboNumVictory.Items.Add(CStr(8))
		comboNumVictory.Items.Add(CStr(12))
		comboNumVictory.Items.Add(CStr(15))
		comboNumVictory.Items.Add(CStr(18))
		
		comboNumEachAction.Items.Add(CStr(10))
		comboNumEachAction.Items.Add(CStr(12))
		comboNumEachAction.Items.Add(CStr(14))
		
		For i = 3 To 10
			comboExhaust.Items.Add(CStr(i))
		Next i
		
		Call cmdRestoreDefaults_Click(cmdRestoreDefaults, New System.EventArgs())
		'UPGRADE_WARNING: Dir has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
		If Dir(My.Application.Info.DirectoryPath & "/settings.txt") = "" Then
			Exit Sub
		End If
		
		' read settings from disk
		FileOpen(1, My.Application.Info.DirectoryPath & "/settings.txt", OpenMode.Input)
		For i = 0 To 5
			Input(1, str_Renamed)
			txtName(i).Text = str_Renamed
		Next i
		
		Input(1, str_Renamed)
		comboNumPlayers.Text = str_Renamed
		For i = Val(str_Renamed) To 5
			lblName(i).Visible = False
			txtName(i).Visible = False
		Next i
		
		Input(1, str_Renamed)
		comboNumActions.Text = str_Renamed
		
		Input(1, str_Renamed)
		comboExhaust.Text = str_Renamed
		
		Input(1, str_Renamed)
		comboNumVictory.Text = str_Renamed
		
		Input(1, str_Renamed)
		comboNumEachAction.Text = str_Renamed
		
		Input(1, str_Renamed)
		chkAutoEnd.CheckState = Val(str_Renamed)
		
		Input(1, str_Renamed)
		chkSound.CheckState = Val(str_Renamed)
		
		Input(1, str_Renamed)
		chkInterface.CheckState = Val(str_Renamed)
		
		FileClose(1)
		
		
	End Sub
	
	
	Private Sub settings_FormClosed(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
		End
	End Sub
End Class